if(typeof(SYS.Module)=='undefined')
{
	SYS.Module = function(moduleInfo, options, success)
	{
		$.extend(this, moduleInfo);

		this.path = SYS.modules[this.name].path;
		this.moduleName = this.name;
		if(options) {
			$.extend(this, options);
		}
		this.initModule(this.id, success);
	}
	SYS.Module.prototype = {
		isReady:false,
		initModule:function(blockId, success)
		{
			this.id = blockId;
			if(typeof(SYS.blocks[this.id]) == 'undefined')
			{
				SYS.blocks[this.id] = this;
			}
			this.init(success);
		},
		buildURL:function(options){
			if(!options)
			{
				options = {};
			}
			options.url_mode = SYS.urlMode;
			// khoanb Edit 21.04.09
			var url = rootURL+'?'+((options && options['module'])?'':'module='+this.moduleName)+'&module_id='+this.id+'&nd='+(new Date()).getTime();
			if(options)
			{
				for(var i in options)
				{
					url += '&'+i+'='+encodeURI(options[i]);
				}
			}
			return url;
		},
		submitURL:function(options){
			return this.buildURL(options)+'&submit_form_id='+this.id;
		},
		init:function(success)
		{
			if(success && typeof(success) == 'function')
			{
				success.call(this);
			}
			this.isReady = true;
		},
		reload: function(params)
		{
			var modules = $('#module-content'+this.id);
			if(modules.length > 0)
			{
				modules.load(this.submitURL({cmd:'redraw'}), params);
			}
		},
		formSignature:function()
		{
			return '<input type="hidden" value="'+this.id+'" name="submit_form_id">';
		},
		jm:function()
		{
			return 'SYS.blocks['+this.id+']';
		},
		canView:function()
		{
			return SYS.User.canView(this.moduleName);
		},
		canViewDetail:function()
		{
			return SYS.User.canViewDetail(this.moduleName);
		},
		canAdd:function()
		{
			return SYS.User.canAdd(this.moduleName);
		},
		canEdit:function()
		{
			return SYS.User.canEdit(this.moduleName);
		},
		canAdmin:function()
		{
			return SYS.User.canAdmin(this.moduleName);
		},
		canModerator:function()
		{
			return SYS.User.canModerator(this.moduleName);
		},
		canDeveloper:function()
		{
			return SYS.User.canDeveloper(this.moduleName);
		},
		closeTab:function(obj)
		{
			currentWorkspace.closeTab(obj);
		}
	}
}